function  recursionFun(data,detail,number){
  let indexArr = [];
  if(String(detail.index).indexOf("-") != -1){
	indexArr = detail.index.split("-");//下标集合
  }else{
	  indexArr.push(detail.index)
  }
  let NumberLayer= number?number:indexArr.length;//当前未处理层次数
  let isChecked= (detail.data.checked?true:false);
  let nowData = ''
  //清空 选项
  if(NumberLayer == indexArr.length && detail.chooseType == 'radio'){
  	   clearSelect(data)
  }
  //当前点击项目
   if(NumberLayer == 1){
		data[indexArr[indexArr.length - 1]].checked = isChecked
		if(detail.selectAll){
			if(data[indexArr[indexArr.length - NumberLayer]].childMenus){
				if(data[indexArr[indexArr.length - NumberLayer]].childMenus.length>0){
					data[indexArr[indexArr.length - NumberLayer]].childMenus =  forEachChil(data[indexArr[indexArr.length - NumberLayer]].childMenus,detail.chooseType,isChecked)
				}
			}
		}
		nowData = data[indexArr[indexArr.length - 1]]
   }else{
	   //父级逐级关联是否触发
	   if(detail.selectRelevance){
		   if(!data[indexArr[indexArr.length - NumberLayer]].disable){
			data[indexArr[indexArr.length - NumberLayer]].checked = isChecked 
		   }
	   }
	    recursionFun(data[indexArr[indexArr.length - NumberLayer]].childMenus,detail,NumberLayer - 1)
   }
  return data
}
function forEachChil(data,type,isChecked){
	  if(type == 'radio'){
		  for (let i = 0; i < data.length; i++) {
			  if(!data[i].disable){
				  data[i].checked = isChecked
				  if(data[i].childMenus){
						  if(data[i].childMenus.length>0){
							  forEachChil(data[i].childMenus,'radio',isChecked)
						  }
				  }
				  break;
			  }
		  }
	  }else if(type == 'checkbox'){
		  for (let i = 0; i < data.length; i++) {
			  if(!data[i].disable){
				  data[i].checked = isChecked
			  }
			if(data[i].childMenus){
				if(data[i].childMenus.length>0){
					forEachChil(data[i].childMenus,'checkbox',isChecked)
				}
			}
			
		  }
	  }
	  return data
  }
function clearSelect(data){
  	  for (let i = 0; i < data.length; i++) {
			data[i].checked = false
			if(data[i].childMenus){
				if(data[i].childMenus.length>0){
					clearSelect(data[i].childMenus)
				}
			}
  	  }
  	  return data
  } 
module.exports = {
	recursionFun
}